/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uit.tkorg.coauthorgraph.servlet.crawl;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import uit.tkorg.coauthorgraph.dto.CrawlAuthorDTO;
import uit.tkorg.coauthorgraph.dto.PaperDTO;
import uit.tkorg.coauthorgraph.property.file.MASearchCrawlPatterns;
import uit.tkorg.coauthorgraph.utility.CommonHTMLProcessor;
import uit.tkorg.coauthorgraph.utility.MASFetcher;
import uit.tkorg.coauthorgraph.utility.MASResultAnalyze;

/**
 * @author Tin Huynh
 *
 */
public class MASManualCrawlingServlet extends HttpServlet {
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        String authorName = request.getParameter("authorName");
        MASFetcher fetcher = new MASFetcher();
        String _pageContent = fetcher.fetchHTMLContentForAuthor(authorName);
        CommonHTMLProcessor htmlParser = new CommonHTMLProcessor();
        ArrayList publicationList =  MASResultAnalyze.getPublications(_pageContent, authorName);
        HttpSession session = request.getSession();
        session.setAttribute("publicationList", publicationList);
        RequestDispatcher dispatcher = request.getRequestDispatcher("./jsp/MASManualCrawling.jsp");
    }
}
